package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.BigTheme;
import cn.wolfcode.luowowo.article.mapper.BigThemeMapper;
import cn.wolfcode.luowowo.article.query.BigThemeQuery;
import cn.wolfcode.luowowo.article.service.IBigThemeService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;

@Service
public class BigThemeServiceImpl implements IBigThemeService {
    @Autowired
    private BigThemeMapper bigThemeMapper;

    @Override
    public PageInfo query(BigThemeQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        return new PageInfo(bigThemeMapper.selectForList(qo));
    }

    @Override
    public BigTheme get(Long id) {
        return bigThemeMapper.selectByPrimaryKey(id);
    }

    @Override
    public void saveOrUpdate(BigTheme bigTheme) {

        if(bigTheme.getId() == null){
            bigThemeMapper.insert(bigTheme);
        }else{
            bigThemeMapper.updateByPrimaryKey(bigTheme);
        }
    }


    @Override
    public List<BigTheme> list() {
        return bigThemeMapper.selectAll();
    }

}
